运行一段kafka streams程序的时候,报出以下异常
1 | Properties settings = new Properties(); |
1 | Exception in thread "StreamThread-1" org.apache.kafka.streams.errors.StreamsException: stream-thread [StreamThread-1] Failed to rebalance |
从异常信息上看是topic:my-first-streams-application1-COUNTS1-changelog不存在。这个topic是kafka streams的内部topic,用于保存state store的changelog。topic的命名格式是:<application.id>-
联想到用kafka-topics.sh是需要传入zookeeper地址的,因为topic的metadata会保存在zk中,那么kafka streams也应该在配置中指定zk地址才能创建topic,加上以下配置之后程序就能跑起来了
1 | settings.put(StreamsConfig.ZOOKEEPER_CONNECT_CONFIG, "10.128.74.83:2181"); |